#region Assembly System.Windows.dll, v2.0.50727
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone\System.Windows.dll
#endregion

using System;
using System.ComponentModel;
using System.Security;
using System.Threading;

namespace System.Windows.Threading
{
  // Summary:
  //     Provides services for managing the queue of work items for a thread.
  public sealed class Dispatcher
  {
    private int _threadId = 0;

    public static Dispatcher CurrentDispatcher
    {
      get
      {
        Dispatcher returnDispatcher;
        returnDispatcher = Thread.GetData(Thread.GetNamedDataSlot("Dispatcher")) as Dispatcher;
        if (returnDispatcher == null)
        {
          returnDispatcher = new Dispatcher();
          returnDispatcher._threadId = Thread.CurrentThread.ManagedThreadId;
          Thread.SetData(Thread.GetNamedDataSlot("Dispatcher"), returnDispatcher);
        }
        return returnDispatcher;
      }
    }

    // Methods
    [SecuritySafeCritical]
    private Dispatcher()
    {
    }

    public DispatcherOperation BeginInvoke(Action a)
    {
      DispatcherOperation returnOperation = new DispatcherOperation();
      IAsyncResult result = a.BeginInvoke(null, null);
      
      //Return operation not implemented
      return returnOperation;
    }

    public DispatcherOperation BeginInvoke(Delegate d, params object[] args)
    {
      throw new NotImplementedException();
    }

    public bool CheckAccess()
    {
      return (Thread.CurrentThread.ManagedThreadId == this._threadId);
    }
  }
}
